package main

import (
	"fmt"
	"strconv"
)

type RoleItemReadNode struct {
	ServerId  int64
	Id        uint64
	Name      string
	Account   string
	rowFields []interface{}
	rowBytes  [][]byte
}

func (role *RoleItemReadNode) Init() {
	role.rowFields = make([]interface{}, 9)
	role.rowBytes = make([][]byte, 9)
	for idx, _ := range role.rowFields {
		role.rowFields[idx] = &role.rowBytes[idx]
	}
}

func (role *RoleItemReadNode) Parse() {
	role.ServerId, _ = strconv.ParseInt(string(role.rowBytes[0]), 10, 32)
	role.Id, _ = strconv.ParseUint(string(role.rowBytes[1]), 10, 64)
	role.Name = string(role.rowBytes[2])
	role.Account = string(role.rowBytes[3])
}

func (role *RoleItemReadNode) String() string {
	return fmt.Sprintf("%d,%d,%s,%s", role.ServerId, role.Id, role.Name, role.Account)
}

func (role *RoleItemReadNode) GetItemData(idx int) []byte {
	return role.rowBytes[idx+4]
}
